package com.yuanfeng.payment.controller;

import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.payment.dto.CardMemberDetailDTO;
import io.seata.core.exception.TransactionException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @ClassName PayUserResourceController
 * @Description 用户资源
 * @Author hyq
 * @Date 2023/6/19 13:56
 * @Version 1.0
 **/
@RestController
@RequestMapping("payment/userResource")
public class PayUserResourceController extends  BaseController{


    /**
     * 钱包余额展示
     *
     * @param map
     * @return
     */
    @PostMapping("/balanceDisplay")
    public ResponseResult balanceDisplay(@RequestBody Map<String, Object> map) {
        ResponseResult result = payUserResourceService.balanceDisplay(map);
        return result;
    }

    /**
     * 增加卖家金额
     *
     * @param map
     * @return
     */
    @PostMapping("/addMoney")
    public ResponseResult addMoney(@RequestBody Map<String, Object> map) {
        ResponseResult isUpdateSuccess = payUserResourceService.addMoney(map);
        return isUpdateSuccess;
    }

    /**
     * 用户余额提现
     *
     * @param map
     * @param request
     * @return
     */
    @PostMapping("/withdrawal")
    public ResponseResult withdrawal(@RequestBody Map<Object, Object> map, HttpServletRequest request) {
        ResponseResult result = payUserResourceService.withdrawal(map, request);
        return result;
    }

    /**
     * 用户转账
     *
     * @param map
     * @return
     */
    @PostMapping("/transfer")
    public ResponseResult transfer(@RequestBody Map<Object, Object> map) {
        ResponseResult result = payUserResourceService.transfer(map);
        return result;
    }

    /**
     * 平台查询 会员充值
     *
     * @param param
     * @return
     * @throws TransactionException
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody CardMemberDetailDTO param) throws TransactionException {
        ResponseResult result = payUserResourceService.updateCardMemberDetailPort(param);
        return result;
    }


    /**
     * 平台查询 会员充值列表
     *
     * @param map
     * @return
     */
    @PostMapping("/query")
    public ResponseResult query(@RequestBody Map<String, Object> map) {
        ResponseResult result = payUserResourceService.query(map);
        return result;
    }
}
